using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace PagesList
{
    public partial class Pages : UserControl
    {
        public Pages()
        {
            InitializeComponent();
            CreatePages();
        }

        private void CreatePages()
        {
            pagesList = new ArrayList();
            pagesList.Add(new PageFirst());
            pagesList.Add(new SecondPage());
            pagesList.Add(new ThirdPage());
            pagesList.Add(new XangMuPage());
            pagesList.Add(new RiTaiZhangPage());
            pagesList.Add(new MonthTaizhang());

            current = (UserControl)pagesList[0];
            this.Controls.Add(current);
            current.Size = this.Size;
        }

        public void ShowPage(int index)
        {
            if (index == -1)
            {
                this.Controls.Remove(current);
                current = null;
                return;
            }
            if (index >= pagesList.Count)
            {
                return;
            }

            if (current == (UserControl)pagesList[index])
            {
                return;
            }

            this.Controls.Remove(current);
            current = (UserControl)pagesList[index];
            this.Controls.Add(current);
            current.Size = this.Size;
        }        

        private UserControl current = null;
        private ArrayList pagesList = null;

        private void Pages_Resize(object sender, EventArgs e)
        {
            this.current.Size = this.Size;
        }
    }
}